package com.sentiment.tools;

import java.util.Random;

public class Generator {
	private static Random random = new Random(System.currentTimeMillis());
/**
 * 生成从begin到end的随机整数
 * @param begin
 * @param end
 * @return
 */
	public static int generateInt(int begin, int end) {
		int rdInt = random.nextInt(end - begin) + begin;
		return rdInt;
	}
/**
 * 生成begin到end的随机浮点数
 * @param begin
 * @param end
 * @return
 */
	public static double genenrateDouble(double begin, double end) {
		return begin + random.nextDouble() * (end - begin);
	}

	public static String getRandomString(int length) { // length表示生成字符串的长度
		String base = "abcdefghijklmnopqrstuvwxyz";
		Random random = new Random();
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < length; i++) {
			int number = random.nextInt(base.length());
			sb.append(base.charAt(number));
		}
		return sb.toString();
	}
/**
 * 生成随机关键词-“关键词1-10”
 * @return
 */
	public static String generateKeyword() {
		int randomNum = generateInt(1,10);
		switch(randomNum){
		case 1: 
			return "关键词1";
		case 2:
			return "关键词2";
		case 3:
			return "关键词3";
		case 4:
			return "关键词4";
		case 5:
			return "关键词5";
		case 6:
			return "关键词6";
		case 7:
			return "关键词7";
		case 8:
			return "关键词8";
		case 9:
			return "关键词9";
		case 10:
			return "关键词10";
		default:
			return "哈哈哈";
		}
	}

}
